package order.controller;


import feign.AccountFeign;
import feign.ProductFeign;
import lombok.extern.slf4j.Slf4j;
import order.entity.Order;
import order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lh
 * @since 2020-08-08
 */
@RestController
@RequestMapping
@Slf4j
public class OrderController {
    @Autowired
    private IOrderService orderService;

    @GetMapping("/order/{id}")
    public Order getByCode(@PathVariable Integer id) {
        log.info("get order detail,id is :{}", id);
        return orderService.getById(id);
    }

    @PostMapping("/order/update")
    public boolean update(@RequestBody Order Order) {
        log.info("update order:{}", Order);
        return orderService.updateById(Order);
    }

    @PostMapping("/order/insert")
    public void insert(@RequestBody Order Order) {
        log.info("insert order:{}", Order);
         orderService.createOrder(Order);
    }

    @PostMapping("/order/delete")
    public boolean delete(@RequestParam Integer id) {
        log.info("delete order,id is {}", id);
        return orderService.removeById(id);
    }

}
